{include file="public/header" /}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .btn-active {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            <div class="row row-lg">

                <div style="display:block;clear: both;"></div>
                <div class="fixed-table-toolbar">

                </div>
                <div class="example">
                    <form class="form-horizontal" method="post">
                        <table id="table_area" data-toggle="table" data-striped="false">
                            <thead>
                            <tr>

                                <th >名称</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}

                            <tr id="id_{$vo.id}" class="class_0">
                                <td class="categoryTitle"><span class="space"></span><span style="cursor:pointer" onclick="op(this,{$vo.id})">[+]</span> [ID: {$vo.id}] [{$vo.username}] [{$vo.nickname}] [{if $vo.is_company}公司{else}{$vo.level_name}{/if}]{if $vo.identity>0}[{$identitys[$vo.identity]}]{/if}</td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>



        </div>
    </div>
</div>
{include file="public/footer" /}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.css"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.js"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table-zh-CN.min.js"}
<script type="text/javascript">
    function add(url) {
        layer.open({
            type: 2,
            title: '内容管理',
            shadeClose: false,
            shade: 0.2,
            area: ['80%', '95%'],
            skin: 'shangchuantup',
            // shift:-1,
            content: url,
        });
    }


</script>

<script>
    function op(object,pid) {
        var tr_object= $(object).parent().parent();

        if ($(object).text() == "[+]") {
            $(object).text("[-]");

            if($('tr').hasClass('class_'+pid)){
                $('.class_'+pid).show();
                return;
            }

            $.ajax({
                url: "{:url('Member/recommendTree')}",
                type: 'POST',
                dataType: 'JSON',
                data: {pid: pid},
                success: function (res) {
                    var json=eval("("+res+")")
                    if (json.status == 1) {
                        var data = json.data;

                        var html='';
                        var new_class = tr_object.attr('class')+' class_'+pid;
                        $(data).each(function (index,value) {
                            var space = $(object).parent().children(".space").html()+"&nbsp;&nbsp;&nbsp;&nbsp;";
                            var level_name =value.level_name;
                            var identitys =[];{foreach $identitys as $key_name=>$key_value} identitys[{$key_name}] = "{$key_value}";{/foreach}
                            var identity_str =  value.identity>0? ' ['+identitys[value.identity]+']':'';

                            if(value.is_company==1) level_name='公司';
                            html +='<tr id="id_'+value.id+'" class="'+new_class+'">\n' +
                                '    <td class="categoryTitle">' +
                                '       <span class="space">'+space+'</span>' +
                                '       <span style="cursor:pointer" onclick="op(this,'+value.id+')">[+]</span>' +
                                '           [ID: '+value.id+'] ['+value.username+' ['+value.nickname+'] ['+level_name+']'+identity_str+
                                    '</td>\n'
                                '</tr>';
                        });
                        tr_object.after(html);
                    }
                },
                error: function () {
                    layer.msg('网络错误', {icon: 2, time: 3000});
                }
            });

        } else {
            $(object).text("[+]");
            $('.class_'+pid).hide();
        }
    }
    function del(id){
        swal_del(id,"{:url('AreaDel')}", {title: '该内容'})
    }
</script>